package tt.com.deadcold.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tt.com.common.enums.Status;
import tt.com.common.model.ColdRoom;
import tt.com.common.model.DeadColdRoom;
import tt.com.common.util.CommonResult;
import tt.com.deadcold.mapper.ColdMapper;
import tt.com.deadcold.mapper.DeadColdMapper;
import tt.com.deadcold.mapper.colddeadMapper;
import tt.com.deadcold.service.DeadColdRegister;

import java.util.Date;

@Service
public class DeadColdRegisterImpl  extends ServiceImpl<colddeadMapper, DeadColdRoom> implements DeadColdRegister {
    @Autowired
    private ColdMapper coldMapper;

    @Override
    public CommonResult recordtime(DeadColdRoom deadColdRoom, ColdRoom coldRoom, Date lastUpdateTime, String lastUpdateUserId) {
        if (deadColdRoom==null){
            //没有业务的话可以预约登记
           baseMapper.insert(deadColdRoom);
           //判断格位是否被启用，0为为启用 1为启用
        }else if (coldRoom.getColdStatus()==1){
            //如果为1的话，则换一个格位id
            coldMapper.updateById(coldRoom);
        }
            baseMapper.updateById(deadColdRoom);
        return CommonResult.buildR(Status.OK,"登记成功");
    }
}
